/**
 * License would add here
 */

#ifndef UTILS_LOG_H
#define UTILS_LOG_H

#ifndef ABORT_WITH_FATAL
#define ABORT_WITH_FATAL 1
#endif

#include <iostream>
#include <ostream>
#include <sstream>

#ifndef USE_HILOG
enum class LogLevel {
    LOG_DEBUG = 2,
    LOG_INFO,
    LOG_WARN,
    LOG_ERROR,
    LOG_FATAL,
};
#else
#include <hilog/log.h>
#endif

class Logger {
public:
    explicit Logger(LogLevel level);
    Logger(LogLevel level, const char* tag);
    Logger(LogLevel level, unsigned int domain, const char* tag);
    ~Logger();
    template <class T>
    std::ostream& operator<<(T input)
    {
        stream_ << input;
        return stream_;
    }

private:
    void LoggerPrinter();

    static std::string GetTime();

    LogLevel level_ { LogLevel::LOG_DEBUG };
    unsigned int domain_;
    std::string tag_;
    std::ostringstream stream_;
};

#endif /* UTILS_LOG_H */